package com.zbf.多线程;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/16  11:19
 * 描述:
 */
public class TestTread002 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        /*Thread t1=new Thread(new TestRunable1(1),"A");
        Thread t2=new Thread(new TestRunable1(2),"B");
        Thread t3=new Thread(new TestRunable1(3),"C");
        Thread t4=new Thread(new TestRunable1(4),"D");

        t1.start();
        t2.start();
        t3.start();
        t4.start();*/


        FutureTask<Integer> task1=new FutureTask<>(new MyCallable(1));
        FutureTask<Integer> task2=new FutureTask<>(new MyCallable(2));
        FutureTask<Integer> task3=new FutureTask<>(new MyCallable(3));
        FutureTask<Integer> task4=new FutureTask<>(new MyCallable(4));


        Thread t1=new Thread(task1,"A");
        Thread t2=new Thread(task2,"B");
        Thread t3=new Thread(task3,"C");
        Thread t4=new Thread(task4,"D");

        t1.start();
        t2.start();
        t3.start();
        t4.start();


        Integer integer1 = task1.get();
        Integer integer2 = task2.get();
        Integer integer3 = task3.get();
        Integer integer4 = task4.get();

        System.out.println("---------->"+integer1+"---"+integer2+"---"+integer3+"---"+integer4);


        System.out.println("=================================");


    }
}
